@extends('admin.app')

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      红包活动列表
    </div>
    <div class="panel-body">
      <form action="{{ admin_action('Gift\ActivityController@index') }}"  class="form-horizontal">
        <div class="form-group">
          <div class="col-sm-1 control-label">名称</div>
          <div class="col-sm-2">
            <input type="text" class="form-control" name="search" value="{{ $query['search'] ?? '' }}" placeholder="请输入查询条件">
          </div>
          <div class="col-sm-8 text-right">
            <button class="btn btn-primary" type="submit">查询</button>
            <a class="btn btn-default btn-addon" href="{{ admin_action('Gift\ActivityController@create') }}">
              <i class="fa fa-plus"></i>新增红包活动
            </a>
          </div>
        </div>
      </form>
      <div class="table-responsive">
        <table class="table table-striped b-t b-light">
          <thead>
            <tr>
              <th>名称</th>
              <th>总金额(元)</th>
              <th>已发金额(元)</th>
              <th>类型</th>
              <th>活动开始时间</th>
              <th>活动结束时间</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            @forelse ($list as $row)
            <tr>
              <td>
                <a href="{{admin_action('Gift\ActivityController@show', [$row])}}" data-toggle="tooltip" title="查看活动信息">{{ $row->name }}</a>
              </td>
              <td>{{ $row->total_money }}</td>
              <td>{{ $row->used_money }}</td>
              <td>{{ $row->type()->name }}</td>
              <td>{{ $row->begin_time }}</td>
              <td>{{ $row->end_time }}</td>
              <td>{{ $row->status()->name }}</td>
              <td>
                @if($row->status==0)
                <a class="btn btn-xs btn-success" href="{{ admin_action('Gift\ActivityController@start', [$row]) }}" data-toggle="tooltip" title="启用该活动">
                  启用
                </a>
                <a class="btn btn-xs btn-primary" href="{{ admin_action('Gift\ActivityController@edit', [$row]) }}" data-toggle="tooltip" title="编辑活动信息">
                  <i class="fa fa-pencil"></i>
                </a>
                @else
                <a class="btn btn-xs btn-primary" href="{{ admin_action('Gift\RecordController@index', [$row]) }}" data-toggle="tooltip" title="查看红包领取记录">
                  领取记录
                </a>
                @endif
                @if($row->status==1)
                 <a class="btn btn-xs btn-danger" href="{{ admin_action('Gift\ActivityController@start', [$row]) }}" data-swal-role="delete-confirm" title="结束活动">
                  结束
                </a>
                @endif
                <a class="btn btn-xs btn-info" href="{{ admin_action('Gift\ActivityController@show', [$row]) }}" data-toggle="tooltip" title="查看该活动详情">
                  <i class="fa fa-info"></i>
                </a>
              </td>
            </tr>
            @empty
            <tr>
              <td colspan="5" class="text-center">没有找到活动记录</td>
            </tr>
            @endforelse
          </tbody>
        </table>
      </div>
    </div>
    <div class="panel-footer">
      <div class="row">
        <div class="col-sm-12 text-right text-center-xs">                
          {{ $links }}
        </div>
      </div>
    </div>
  </div>
@endsection